package com.example.cqh_votesys.controller;

import com.example.cqh_votesys.pojo.DTO.RegisterDTO;
import com.example.cqh_votesys.pojo.pojo.User;
import com.example.cqh_votesys.pojo.result.Result;
import com.example.cqh_votesys.sevice.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: pollux
 * @CreateTime: 2024-06-29
 * @Description: 登录控制类
 * @Version: 1.0
 */

@RestController
@RequestMapping()
@Slf4j
@CrossOrigin(origins = "*")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     *
     * @description: 登录接口
     * @param user 用户实体类
     * @return: com.example.cqh_votesys.pojo.result.Result
     * @author: pollux
     * @date: 2024/6/30 14:18
     */
    @PostMapping("/login")
    public Result<String> login(@RequestBody User user){
        log.info("用户登录，{}",user);
        String jwt = loginService.login(user);
        return Result.success(jwt);
    }

}
